package com.study;

import com.study.util.FileUtil;

import java.util.ArrayList;
import java.util.List;

public class Test {

    private static final String url = "https://share-open-platform.qa.91jkys.com/api_search?search=";

    public static void main(String[] args) {
        List<String> strings = FileUtil.readTxtFileIntoStringArrList(
                "/Users/wanghuilong/IdeaProjects/lazy/src/main/resources/file/2.txt", null);
        List<Item> itemList = new ArrayList<>();
        List<String> temp = new ArrayList<>();
        for (int i = 0; i < strings.size(); i++) {
            if (i % 5 == 0 && temp.size() == 5) {
                Item item = new Item(temp.get(1), temp.get(3), temp.get(4));
                itemList.add(item);
                temp = new ArrayList<>();
            }
            temp.add(strings.get(i));
        }

        for (int i = 0; i < itemList.size(); i++) {
            Item item = itemList.get(i);
            String m = item.method.substring(0, item.method.indexOf("("));
            String interfaceStr = item.service + "." + m;
            System.out.println(item.name);
            System.out.println(interfaceStr);
            System.out.println("接口文档：" + url + m);
            System.out.println();
        }
    }

    static class Item {
        public String service;

        public String method;

        public String name;

        public Item(String service, String method, String name) {
            this.service = service;
            this.method = method;
            this.name = name;
        }

        @Override
        public String toString() {
            return "Item{" +
                    "service='" + service + '\'' +
                    ", method='" + method + '\'' +
                    ", name='" + name + '\'' +
                    '}';
        }
    }
}
